package com.qbhy.poster.kernal.smms;

import com.qbhy.poster.contracts.Result;
import com.qbhy.poster.contracts.Uploader;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;

@Service
public class SmmsUploader implements Uploader {
    @Override
    public Result upload(File file) throws IOException {
        return result;
    }
//
//    public static final MediaType IMAGE = MediaType.parse("application/octet-stream");
//
//    public static OkHttpClient client = new OkHttpClient();
//
//    public static Result push(File file) throws IOException {
//        return (new SmmsUploader()).upload(file);
//    }
//
//    public Result upload(File file) throws IOException {
//
//        RequestBody requestBody = new MultipartBody.Builder()
//                .setType(MultipartBody.FORM)
//                .addFormDataPart("smfile", file.getName(), RequestBody.create(IMAGE, file))
//                .build();
//
//        Request request = new Request.Builder()
//                .addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36")
//                .addHeader("Accept", "application/json, text/javascript, */*; q=0.01")
//                .url("https://sm.ms/api/upload")
//                .post(requestBody)
//                .build();
//
//        try (Response response = client.newCall(request).execute()) {
//            return (SmmsUploadResult) JsonableInterface.decode(response.body().string(), SmmsUploadResult.class);
//        }
//    }
}
